package com.apes.scm.masterdata.product.service;

import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import com.apes.scm.masterdata.product.model.MaterialUsage;
import com.apes.scm.masterdata.product.repository.MaterialUsageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName MaterialUsageService
 * @Description TODO
 * @Author pengyb
 * @Date 2019/12/24 17:45
 * @Version 1.0
 **/
@Service("materialUsageService")
public class MaterialUsageService extends DomainService {
    MaterialUsageRepository materialUsageRepository;

    @Autowired
    private void setMaterialUsageRepository(MaterialUsageRepository materialUsageRepository) {
        this.materialUsageRepository = materialUsageRepository;
    }

    public MaterialUsage save(SimpleRequest request) {
        MaterialUsage usage = request.getO(MaterialUsage.class);
        return materialUsageRepository.saveAndFlush(usage);
    }

    public String delete(SimpleRequest request) {
        MaterialUsage usage = request.getO(MaterialUsage.class);
        materialUsageRepository.delete(usage);
        return "删除成功";
    }
}
